package nc.bs.gsp.hf058805;

import java.util.Collection;

import nc.bs.medpub.pub.MedQueryDMO;
import nc.vo.gsp.hf058805.BLFYBGBVO;
import nc.vo.gsp.hf058805.BLFYBGHVO;
import nc.vo.gsp.pub.GspConst;
import nc.vo.jcom.lang.StringUtil;
import nc.vo.pub.BusinessException;
import nc.vo.pub.CircularlyAccessibleValueObject;

public class GspBlfydjDMO extends MedQueryDMO {

	@Override
	protected String getBillType() {
		return GspConst.BLFYDJ;
	}

	@Override
	protected Class<?> getHeadVOClass() throws BusinessException {
		return BLFYBGHVO.class;
	}

	@Override
	protected Class<?> getBodyVOClass() throws BusinessException {
		return BLFYBGBVO.class;
	}

	public CircularlyAccessibleValueObject[] queryAllHeadData(String whereString) throws BusinessException {
		String strWhere = " nvl(dr,0)=0 ";
		if (!StringUtil.isEmptyWithTrim(whereString)) {
			strWhere += " and (" + whereString + ")";
		}
		Collection rs = getDao().retrieveByClause(BLFYBGHVO.class, strWhere);
		if (rs != null && !rs.isEmpty()) {
			return (BLFYBGHVO[]) rs.toArray(new BLFYBGHVO[0]);
		}
		return null;
	}

	public CircularlyAccessibleValueObject[] queryAllBodyData(String key, String whereString) throws BusinessException {
		if (StringUtil.isEmptyWithTrim(key)) {
			return null;
		}
		StringBuffer sb = new StringBuffer("");
		sb.append(BLFYBGHVO.PK).append("='").append(key).append("'");
		sb.append(" and nvl(dr,0)=0 ");
		if (!StringUtil.isEmptyWithTrim(whereString)) {
			sb.append(" and (").append(whereString).append(")");
		}
		Collection rs = getDao().retrieveByClause(BLFYBGBVO.class, sb.toString());
		if (rs != null && !rs.isEmpty()) {
			return (BLFYBGBVO[]) rs.toArray(new BLFYBGBVO[0]);
		}
		return null;
	}

}
